<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>后台管理</title>
</head>
<script type="text/javascript" src=" js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link href="css/sweet-alert.min.css" rel="stylesheet" />
<script src="js/sweet-alert.min.js"></script>
</script>
<script type="text/javascript">
 $(function(){
	 
	 setTimeout(function(){
			$("#p1").attr("style","display:none");
		},2000);
	 setTimeout(function(){
		 swal("想啥那 !")
		 
	 },10000);  
	 setTimeout(function(){location.reload()},300000);
	 $.post(
	"fenlei.do",
	function(data){
		for (var i = 0; i <data.length; i++) {
			$("[name='fid']").append("<option value='"+data[i].fid+"'> "+data[i].fname+"</option>"); 
			}
		},
	"json"
	 );
	 
 });
 
 function yc(){
		$("#t2").attr("style","display:none");
		$("#p2").show();
	 
 }
</script>
<body>

	<center>
		<div id="p1">
			<font color="red">
				<h3 onclick="dj()">前台设计人员跑光了</h3>
			</font>
		</div>
		<br> <br>
		<div style="width: 1000px;">
			<div class="container-fluid">
				<div class="row-fluid">
					<div role="tabpanel">
						<ul class="nav nav-tabs">
							<li class="active"></li>
							<li><input type="button" onclick="location.reload()"
								value="文章管理" class="btn btn-primary btn-lg" data-toggle="modal"
								data-target="#myModal"></li>
							<li>&nbsp;&nbsp;<input type="button" value="轮播图管理"
								onclick="yc()" class="btn btn-primary btn-lg">
							</li>
							<li class="dropdown pull-right"><h2>
									<a href="#" data-toggle="dropdown" class="dropdown-toggle">更多操作<strong
										class="caret"></strong></a>
									<ul class="dropdown-menu">
										<li><input type="button" onclick="dj2()" value="联系本页负责人"
											class="btn" class="btn btn-primary btn-lg"></li>
										<li><input type="button" onclick="location='go.do'"
											value="返回首页" class="btn" class="btn btn-primary btn-lg">
										</li>
										<li></li>
										<li class="divider"></li>
									</ul></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="tab-content">
			<br />


			<div id="p2" style="display: none">


				<!-- 按钮触发模态框 -->
				<button class="btn" class="btn btn-primary btn-lg"
					data-toggle="modal" data-target="#myModal">新增轮播图</button>
				<!-- 模态框（Modal） -->
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">&times;</button>
							</div>
							<div class="modal-footer">


								<form action="lunbo.do" method="post"
									enctype="multipart/form-data">
									<div class="form-group">
										<label for="exampleInputEmail1">轮播图中字</label><input
											class="form-control" id="exampleInputEmail1" name="jname"
											placeholder="输入标轮播图中字" />
									</div>
									<div class="form-group">
										<input type=file name="myFile" style="display: none;"
											onchange="ye.value=value"><input name=ye
											style="color: green; border: 1px solid green"> <input
											type=button value="选择图片" onclick=myFile.click()
											style="border: 1px solid green">
									</div>
									<div class="form-group"></div>
									<div class="form-group">
										<select class="form-control" style="width: 200px;" name="fid">
											<option>--文章分类--</option>
										</select>
									</div>
									<div class="form-group"></div>
									<button type="button" class="btn btn-default"
										data-dismiss="modal">关闭</button>
									<button onclick="add()" class="btn btn-default">新增轮播图</button>
								</form>



							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
				&nbsp;&nbsp; <input type="button" value="把选中的卸下" class="btn"
					onclick="sc()">
				<div class="container">
					<div class="row clearfix">
						<div class="col-md-12 column">
							<table class="table">
								<thead>
									<tr>
										<th></th>
										<th>轮换中的字</th>
										<th>轮换图片</th>
									</tr>
								</thead>
								<c:forEach items="${lh }" var="l">
									<tbody>
										<tr class="info">
											<td><br /> <input type="checkbox" value="${l.jid }"
												name="jid"></td>
											<td><br />${l.jname}</td>
											<td><img alt="图片未找到" src="img/${l.jpic }"
												style="width: 100px; height: 100xp;"></td>
										</tr>
									</tbody>
								</c:forEach>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</center>

	<div class="tab-pane" id="t2">
		<br /> <br /> <br />
		<div class="container">
			<input class="form-control" placeholder="请输入选查询的文章 " maxlength="20"
				id="name"> <input type="button" value="查询文章" class="btn"
				onclick="cx()"> <input type="button" value="把选中文章清除"
				class="btn" onclick="sc2()">
			<div class="row clearfix">
				<div class="col-md-12 column">
					<table class="table">
						<thead>
							<tr>
								<th></th>
								<th>文章标题</th>
								<th>文章图片</th>
								<th>发布时间</th>
								<th>修改时间</th>
							</tr>
						</thead>
						<c:forEach items="${all}" var="w">
							<tbody>
								<tr class="info">
									<td><br /> <input type="checkbox" value="${w.wid }"
										name="wid"></td>
									<td><br /><h3>${w.biaoti}</h3></td>
									<td><img alt="图片未找到" src="img/${w.pic }"
										style="width: 100px; height: 100xp;"></td>
										<td><br /> <h3>${w.cdate}</h3></td>
										<td><br /> <h3>${w.udate}</h3></td>
									<td><br /><br /><input type="button" value="修改标题与内容"
									 onclick="xg(${w.wid})" class="btn"></td>
								</tr>
							</tbody>
						</c:forEach>

					</table>

					<center>
						<input type="button" value="&lt;&lt;"
							onclick="location='ht.do?page=1&name=" class="btn"> <input
							type="button" value="&lt;"
							onclick="location='ht.do?page=${p.prevPage}&name='" class="btn">
						<input type="button" value=">"
							onclick="location='ht.do?page=${p.nextPage}&name='" class="btn">
						<input type="button" value=">>"
							onclick="location='ht.do?page=${p.lastPage}&name='" class="btn">
						共条 ${p.count} 篇文章 当前第 ${p.currentPage}/${p.lastPage} 页

					</center>
				</div>
			</div>
		</div>


		<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal2" tabindex="-1" role="dialog"
			aria-labelledby="myModalLabel" aria-hidden="true">

			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">

						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">×</button>
						<form>
							<input type="hidden" value="" name="wid">
							<h4 class="modal-title" id="myModalLabel">
								<input type="text" value="" name="biaoti">
							</h4>
							<h4 class="modal-title" id="myModalLabel">
								<br />
								<textarea rows="20" cols="60" name="leirong"></textarea>
							</h4>
						</form>
					</div>
					<div class="modal-body">按下 ESC 按钮退出。</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<input type="button" class="btn btn-default" value="提交更改"
							onclick="gg()">
					</div>

				</div>
				<!-- /.modal-content -->
			</div>
			<!-- /.modal-dialog -->
		</div>
		<!-- /.modal -->
</body>
<script type="text/javascript">


function gg(){
	var wids=$("[name='wid']").val(); 	
	var biaotis=$("[name='biaoti']").val();	
	var leirongs=$("[name='leirong']").val(); 	
	
	$.post(
			"xg.do",
			{     
				wid:wids,
				biaoti:biaotis,
				leirong:leirongs
			},
			function(data){ if(data){  
				 swal("Good!", "更改成功", "success");
			setTimeout(function(){
            location.reload();
				
			},1000);
			 }else{swal("更改失败!","error");}  },
			"json"
			);
              }


function xg(wids){ 
	$("[name='leirong']").html("");
	
	$.post(
	"huxian.do",
	{wid:wids},
	function(data){
     
		$("[name='wid']").attr("value",data.wid);
		$("[name='biaoti']").attr("value",data.biaoti);
		$("[name='leirong']").append(data.leirong);
	 },
	"json"
	);
	
	$('#myModal2').modal({
    keyboard: true
})}

 function cx(){
var name=$("#name").val();
location="ht.do?name="+encodeURI(encodeURI(name));
 
 }  
		function sc() {
			var jids = "";
			$("[name='jid']:checked").each(function() {
				jids += "," + this.value;
			});
			jids = jids.substring(1);
			if(jids==""){swal("请先选择一张轮播图");}
			else 
			$.post(
			"sc.do",
			{jid:jids},
			function(data){ if(data){  
				swal("卸下轮播图成功!"); 
			setTimeout(function(){
            location.reload();
				
			},1000);
			 }else{swal("卸下失败!");}  },
			"json"
			);
		}
		function sc2() {
			var wids ="";
			$("[name='wid']:checked").each(function() {
				wids += "," + this.value;
			});
			wids = wids.substring(1);
			if(wids==""){swal("请先选择一篇文章");}
			else 
			$.post( 
					"scs.do",
					{wid:wids},
					function(data){ if(data){  
						 swal("清除文章成功!");
					setTimeout(function(){
		            location.reload();
		           
					},2000);
					$("#p2").attr("style","display:none");
					
					 }else{swal("清除文章失败!");}  },
					"json"
					);
		}
		function dj(){swal("无效果")}
		function dj2(){swal("负责人员也跑了 !");}
	</script>
</html>